<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        ul li{
            list-style: none;
        }
    </style>
</head>
<body>
    <h1>宠物列表</h1>
    <a href="/new.html">【新增】</a>
    <ul id="list"></ul>

    <!-- <form action="/api/v1/pets" method="POST">
        <ul id="list"></ul>
    <input type="text" name="name" placeholder="请输入名字">
    <input type="text" name="skills" placeholder="请输输入技能">
    <input type="submit" value="提交"></form> -->

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
        <script>
            $.ajax({
                type: "GET",
                url: "/api/v1/pets",
                success: function (res) {
                    // alert(res)
                    var strHtml = "";
                    res.forEach( (item) => (strHtml += `
                    <li>${item.name}</li>
                    `));
                    $("#list").html(strHtml);
                },
                error:function (msg){
                    console.log(msg);
                }
            });
        </script>
</body>
</html>